<?php

namespace haibao\ad\data;

class DeliveryLog extends \haibao\ad\data\BaseMysql {
	public function __construct() {
		parent::__construct ( '\haibao\ad\model\data\AdSummary' );
	}
	
	public function addImpressionLog($key,$value){
		$cache = new \haibao\ad\cache\AdInfo();
		$len = $cache->addImpressionLog($key, $value);
		if($len == 1){
			$cache->saveCacheKey($cache->cacheImpressionKey.'-'.$key);
		}
	}
	
	public function getImpressionLog($key){
		$cache = new \haibao\ad\cache\AdInfo();
		$data = $cache->getDataByKey($key);
		return $data;
	}
	
	public function saveImpressionLog($key,$time){
		$cache = new \haibao\ad\cache\AdInfo();
		$data = $cache->getDataByKey($key);
		if($data){
			$cache->updateImpressionLog($key, $time);
		}else{
			$cache->setImpressionLog($key,$time);
		}
	}
}
